//utf-8
//点击新增按钮 事件跳转至 新增页面
function toAddData(){
	
	var obj={"text":'新建转让交易',"url":contextRootPath+'/tCMmCooperorgDeal/prepareExecute/toAdd'};
	parent.showObj(obj);
}

//修改 事件
function toUpdateData(){
	var v_ids = iframe.iframeObj["table"].getSelectedIds().join(",");
	
	//如果没有选中 数据则
	if(v_ids == ""){
		alert("请选择待修改的数据！");
		return;
	}
	//如果选择多个 择提示
	if(v_ids.indexOf(",") > -1){
		alert("请选择一条数据！");
		return;
	}
	
	var cooperorgCode = iframe.iframeObj["table"].getSelectedObjs("cooperorgCode");
	var contractCode = iframe.iframeObj["table"].getSelectedObjs("contractCode");
	var creditPackageName = iframe.iframeObj["table"].getSelectedObjs("creditPackageName");
	var dealCode = iframe.iframeObj["table"].getSelectedObjs("dealCode");
	var cooperativeAgencyDealStatus = iframe.iframeObj["table"].getSelectedObjs("cooperativeAgencyDealStatus");
	var obj={"text":'修改转让交易',"url":contextRootPath+'/tCMmContract/prepareExecute/toBackCooperorgDealUpdate?contractCode=' + contractCode + "&creditPackageName=" + creditPackageName + "&dealCode=" + dealCode + "&cooperativeAgencyDealStatus=" + cooperativeAgencyDealStatus + "&cooperorgCode=" + cooperorgCode + "&idDeal=" + v_ids};
	parent.showObj(obj);
}
//债权 结算功能（推送核心） zhoupeng 2016-4-18
function costParameterConfirm(costType){
	var v_ids = iframe.iframeObj["table"].getSelectedIds().join(",");
	var v_ids = iframe.iframeObj["table"].getSelectedIds().join(",");
	var dealCode = $('#dealCode').val();
	//如果没有选中 数据则
	if(v_ids == ""){
		alert("请选择待发送的数据！");
		return;
	}
	var url = contextRootPath + "/tCMmCostParam/costParameterConfirm";

	var param = {"costType":costType,"dealCode":dealCode,"v_ids":v_ids};
	if(confirm("您确认要结算选择的数据吗？")){
		jyAjax(url,param,function(msg){
			alert(msg.msg);
	    	var v_status = msg.status;
	    	if(v_status.indexOf('ok') >-1){
	    		var result=msg.data;
	    		
	    	}
		});
	}
	
	
}


//删除 事件
function deleteData(){
	var v_ids = iframe.iframeObj["table"].getSelectedIds().join(",");
	var dealType = iframe.iframeObj["table"].getSelectedObjs("cooperativeAgencyDealStatus").join(",");
	//如果没有选中 数据则
	if(v_ids == ""){
		alert("请选择待删除的数据！");
		return;
	}
	
	var passage = dealType.indexOf('02');
	var complete = dealType.indexOf('03');
	
	if(passage>-1||complete>-1){
		alert("在途和已完成状态不能删除！");
		return;
	}
	
	if(confirm("您确认要删除选择的数据吗？")){
        $.ajax({
            type:"POST",
            dataType : "json",
            url:contextRootPath+"/cooperorgDeal/deleteDeal?ids="+v_ids,
            success:function(msg){
            	alert(msg.msg);
            	var v_status = msg.status;
            	//删除成功后
            	if(v_status.indexOf('ok') >-1){
            		iframe.iframeObj["table"].removeSelectedRow();
            	}
            	
            	
            }
        });
    }
}

//刷新结算状态
function refreshSettleStatus(){
	$.ajax({
		url: contextRootPath+"/creditDealController/realTimeUpdateSettleResult",
		type: 'post',
		dataType: 'json',
		success: function(msg) {
				jyDialog({"type":"info"}).alert(msg.msg);
				var v_status = msg.status;
		    	if(v_status.indexOf('ok') >-1){
		    		queryData();
		    	}
				
		}
	});
}
